/**
 * 是否开启了wifi网络代理
 * @param context
 * @returns {boolean}
 */
exports.isEnableWifiProxy = function(context) {
    importClass(android.os.Build);
    importClass(android.text.TextUtils);
    IS_ICS_OR_LATER = Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH;
    let proxyAddress;
    let proxyPort;
    if (IS_ICS_OR_LATER) {
        proxyAddress = java.lang.System.getProperty("http.proxyHost");
        portStr = java.lang.System.getProperty("http.proxyPort");
        proxyPort = java.lang.Integer.parseInt(portStr != null ? portStr : "-1");
    } else {
        proxyAddress = android.net.Proxy.getHost(context);
        proxyPort = android.net.Proxy.getPort(context);
    }
    return !TextUtils.isEmpty(proxyAddress) && proxyPort != -1;
}

/**
 * 是否开启了vpn
 * @returns {boolean}
 */
exports.isEnableVpn = function () {
    try {
        var niList = java.net.NetworkInterface.getNetworkInterfaces();
        if (niList) {
            var VPN;
            var arry = java.util.Collections.list(niList).toArray();
            for (ary = 0; ary < arry.length; ary++) {
                if (!arry[ary].isUp() || arry[ary].getInterfaceAddresses().size() == 0) {
                    continue;
                }
                if (arry[ary].getName().search("tun0") !== -1 || arry[ary].getName().search("ppp0") !== -1) {
                    VPN = true;
                    return true;
                } else {
                    VPN = false;
                }
            }
            return VPN;
        }
    } catch (error) {}
}